package com.lanou.dllo.soccernews.database;

import com.lanou.dllo.soccernews.application.BaseApplication;
import com.lanou.dllo.soccernews.bean.greendao.DaoSession;
import com.lanou.dllo.soccernews.bean.greendao.RecommendEntity;

import java.util.List;

import de.greenrobot.dao.query.QueryBuilder;

/**
 * Created by dllo on 15/11/2.
 */
public class RecommendDBhelp {

    private static RecommendDBhelp recommendDBhelp;
    private static DaoSession daoSession;

    private RecommendDBhelp() {

    }

    public static RecommendDBhelp getInstance() {
        if (recommendDBhelp == null) {
            recommendDBhelp = new RecommendDBhelp();
            daoSession = BaseApplication.getDaoSession();
        }

        return recommendDBhelp;
    }

    public List<RecommendEntity> getRecommentEntity() {
        QueryBuilder<RecommendEntity> qb = daoSession.getRecommendEntityDao().queryBuilder();
        return qb.list();
    }

    public void addRecommendEntity (List<RecommendEntity> recommendEntities){
        daoSession.getRecommendEntityDao().insertInTx(recommendEntities);
    }

    public void deleteAll(){
        daoSession.getRecommendEntityDao().deleteAll();
    }

}

